home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / develop / nsplib1_30.lha / NetSupportLibrary / LibraryTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-05  |  4.7 KB  |  133 lines

  1. /*
  2.  *      $Filename: LibraryTest.c $
  3.  *      $Revision$
  4.  *      $Date$
  5.  *
  6.  *      Copyright (C) 1993 by Peter Simons <simons@peti.GUN.de>
  7.  *
  8.  *      This program is free software; you can redistribute it and/or
  9.  *      modify it under the terms of the GNU General Public License as
  10.  *      published by the Free Software Foundation; either version 2 of
  11.  *      the License, or (at your option) any later version.
  12.  *
  13.  *      This program is distributed in the hope that it will be useful,
  14.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *      General Public License for more details.
  17.  *
  18.  *      You should have received a copy of the GNU General Public License
  19.  *      along with this program; if not, write to the Free Software
  20.  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  *
  23.  *      $Id$
  24.  *
  25.  * ------------------------------- log history ----------------------------
  26.  * $Log$
  27.  */
  28.  
  29.  
  30. /**************************************************************************
  31.  *                                                                        *
  32.  * SEKTION: Labels, Macros, Switches, Structures                          *
  33.  *                                                                        *
  34.  **************************************************************************/
  35.  
  36. /************************************* Includes ***********/
  37. #include <stdio.h>
  38. #include <proto/exec.h>
  39. #include <proto/dos.h>
  40. #include <proto/netsupport.h>
  41. #include <libraries/netsupport.h>
  42. #include <exec/memory.h>
  43.  
  44. /************************************* Defines ************/
  45.  
  46. /************************************* Prototypes *********/
  47.  
  48. static const char __RCSId[] = "$Id$";
  49.  
  50. /**************************************************************************
  51.  *                                                                        *
  52.  * SEKTION: Main program                                                  *
  53.  *                                                                        *
  54.  **************************************************************************/
  55.  
  56.  
  57. int __saveds main(void)
  58. {
  59.         struct NetSupportLibrary *NetSupportBase;
  60.         char buffer[256];
  61.         BPTR fh;
  62.         LONG i;
  63.  
  64.         if (!(NetSupportBase = (struct NetSupportLibrary *) OpenLibrary(NETSUPPORTNAME, 0L)))
  65.                 return 10;
  66.  
  67. /*
  68.         AllocMemPooled(240, MEMF_PUBLIC|MEMF_CLEAR);
  69.         FreeMemPooled(AllocMemPooled(240, MEMF_ANY));
  70.  
  71.         Printf("%lu\n", GetSeq(1L));
  72.  
  73.         Printf("%s\n", TempNameT(buffer));
  74.         Printf("%s\n", TempName(NULL));
  75.         Printf("%s\n", TempNameT(buffer));
  76.         Printf("%s\n", TempName(NULL));
  77.         Printf("%s\n", TempName(buffer));
  78.         Printf("%s\n", TempNameT(NULL));
  79.         Printf("%s\n", TempName(buffer));
  80.         Printf("%s\n", TempNameT(NULL));
  81.  
  82.         Printf("%s <%s\n", GetConfig(NULL, RMAIL, NULL, RMAIL), "Test");
  83.         System("LibraryTest2", NULL);
  84.  
  85.         MakeLogEntry(NULL, 0L, "%s:%s", "Test", "Klaus");
  86.         Printf("%s\n", GetConfig("UULIB:PMail.config", "NODENAME", "HOSTNAME", "RAM:"));
  87.         Printf("%s\n", GetConfig(NULL, "NODENAME2", "HOSTNAME", "def"));
  88.  
  89.         Printf("%ld\n", LockFileAttempt("uuspool:Klaus"));
  90.  
  91.         LockFile("uuspool:Klaus");
  92.         if (IsFileLocked("uuspool:Klaus"))
  93.                 printf("Locked!!\n");
  94.         else
  95.                 printf("Not locked!!\n");
  96.  
  97.         Printf("%s\n", GetConfigEntry("RAM:Test", "NodeName", "<not set>"));
  98.         SetConfigEntry("RAM:Test", "NodeName", "badtaste");
  99.         Printf("%s\n", GetConfigEntry("RAM:Test", "NodeName", "<not set>"));
  100.  
  101.         if (fh = POpen("sendmail", MODE_PIPETO)) {
  102.                 FPuts(fh, "To: postmaster\nSubject: NetSupportLibrary Test\n\n");
  103.                 FPuts(fh, "Dies ist nur ein doofer Test von einem doofen Program!\n");
  104.                 PClose(fh);
  105.         }
  106.  
  107.         if (fh = POpen("Type S:Startup-Sequence", MODE_PIPEFROM)) {
  108.                 while(FGets(fh, buffer, 255))
  109.                         FPuts(Output(), buffer);
  110.                 PClose(fh);
  111.         }
  112.  
  113.         MakeLogEntry("Test", MLE_DEBUG1, "Debug1");
  114.         MakeLogEntry("Test", MLE_DEBUG2, "Debug2");
  115.         MakeLogEntry("Test", MLE_DEBUG3, "Debug3");
  116.         MakeLogEntry("Test", MLE_DEBUG4, "Debug4");
  117.         MakeLogEntry("Test", MLE_DEBUG5, "Debug5");
  118.         MakeLogEntry("Test", MLE_DEBUG6, "Debug6");
  119.         MakeLogEntry("Test", MLE_DEBUG7, "Debug7");
  120. */
  121.  
  122.         if (fh = POpen("ListSERV:c/Cat", MODE_PIPETO)) {
  123.                 for (i = 0; i <= 5; i++)
  124.                         FPuts(fh, "Test\n");
  125.                 Printf("RC: %ld\n", PClose(fh));
  126.         }
  127.  
  128.         CloseLibrary((struct Library *) NetSupportBase);
  129.         return 0;
  130. }
  131.  
  132.  
  133.